package example;

import java.util.Arrays;
import java.util.List;

public class Exam002 {

    List<String> arrangeVersion(List<String> versions) {

//        Map<String, Integer> versionPatchCount = new HashMap<>();
//
//
//        for (String version : versions) {
//            if (version.contains("release")) {
//                String[] split = version.split("\\.");
//                versionPatchCount.putIfAbsent(split[1], 0);
//            }
//            if (version.contains("patch")) {
//                String[] split = version.split("\\.");
//                String key = split[1];
//                if (versionPatchCount.get(key) == null) {
//                    versionPatchCount.put(key, 1);
//                }else {
//                    versionPatchCount.put(key, versionPatchCount.getOrDefault(key, 0) + 1);
//                }
//
//            }
//        }
//
//        List<Map.Entry<String, Integer>> infoIds = new ArrayList<Map.Entry<String, Integer>>(versionPatchCount.entrySet());
//
//        Collections.sort(infoIds, new Comparator<Map.Entry<String, Integer>>() {
//            @Override
//            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
//                if (Objects.equals(o1.getValue(), o2.getValue())) {
//                    return Integer.parseInt(o1.getKey()) - Integer.parseInt(o2.getKey());
//                }
//                return o2.getValue() - o1.getValue();
//            }
//        });
//        List<String> result = new ArrayList<>();
//        for (int i = 0; i < infoIds.size(); i++) {
//            String id = infoIds.get(i).getKey();
//            result.add("release:" + id);
//        }

        return List.of();
    }

    public static void main(String[] args) {
        Exam002 exam002 = new Exam002();
        List<String> versions = Arrays.asList("release.21",
                "release.23",
                "patch.21.01",
                "patch.23.02",
                "patch.24.05",
                "release.24",
                "release.09",
                "patch.21.11",
                "patch.23.12",
                "patch.24.01",
                "patch.24.08"
        );
        List<String> strings = exam002.arrangeVersion(versions);
        System.out.println(Arrays.toString(strings.toArray()));
    }
}
